package com.yy.controller;

import com.yy.service.HelloServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

/**
 * @date 2024/5/5
 */
@RestController
@Slf4j
public class HelloServiceController {

    @Autowired
    private HelloServiceImpl helloService;

    @Autowired
    private RestTemplate restTemplate;

    private static final String SERVICE_01_URL = "http://localhost:8081/hello";

    @GetMapping("/hello")
    public String getName() {
        String result = restTemplate.getForObject(SERVICE_01_URL, String.class);
        log.info("通过restTemplate调用service 01服务返回：{}", result);
        return helloService.getName();
    }
}
